
let lastScrollTop = 800;
const backToTopButton = document.querySelector('.youce');
window.addEventListener('scroll', function () {
    let currentScroll = document.documentElement.scrollTop;
    if (currentScroll >= lastScrollTop) {
        // 向下滚动
        backToTopButton.style.opacity = 1;
        // backToTopButton.style.transition = 'all 1s linear'
    } else {
        // 向上滚动
        backToTopButton.style.opacity = 0;
    }
    // lastScrollTop = currentScroll;
}, false);

document.querySelector('.fanhui').addEventListener('click', function () {
    window.scrollTo({
        top: 0,
        left: 0,
        behavior: 'smooth'
    });
});


